// AboutTab.cpp : implementation file
//

#include "stdafx.h"
#include "moretunes.h"
#include "AboutTab.h"
#include ".\abouttab.h"
#include "Register.h"

// CAboutTab dialog

IMPLEMENT_DYNAMIC(CAboutTab, CResizablePage)
CAboutTab::CAboutTab(CPrefTab *prefs)
	: CResizablePage(CAboutTab::IDD)
	, _prefs(prefs)
{
}

CAboutTab::~CAboutTab()
{
}

void CAboutTab::DoDataExchange(CDataExchange* pDX)
{
	CResizablePage::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_EDIT1, _registration);
}


BEGIN_MESSAGE_MAP(CAboutTab, CResizablePage)
	ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
	ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton2)
	ON_BN_CLICKED(IDC_BUTTON3, OnBnClickedButton3)
	ON_WM_PAINT()
END_MESSAGE_MAP()


#define URL_WEBSITE "http://code.google.com/p/moretunes/"

// CAboutTab message handlers

void CAboutTab::OnBnClickedButton1() {
	ShellExecute(NULL, "open", URL_WEBSITE, NULL, NULL, SW_SHOWNORMAL);	
}

#define MESSAGE_REGISTERED ""
void CAboutTab::OnBnClickedButton2() {
	if (_prefs->_registration == REGISTRATION_OK) {
		AfxMessageBox(MESSAGE_REGISTERED, MB_ICONINFORMATION, NULL);
		return;
	}
	CRegister register1(_prefs);
	register1.DoModal();
}

#define MESSAGE_HELP "To launch help press F1"
void CAboutTab::OnBnClickedButton3() {
	AfxMessageBox(MESSAGE_HELP, MB_ICONINFORMATION, NULL);
//	ShellExecute(NULL, "open", URL_WEBSITE_HELP, NULL, NULL, SW_SHOWNORMAL);	
}

#define MESSAGE_ABOUT_NOT ""

#define MESSAGE_ABOUT_YES ""
void CAboutTab::OnPaint()
{
	CPaintDC dc(this); // device context for painting
	if (_prefs->_registration == REGISTRATION_OK) {
		CString message = MESSAGE_ABOUT_YES;
		message += _prefs->_name;
		_registration.SetWindowText(message);
	}
	else 
		_registration.SetWindowText(MESSAGE_ABOUT_NOT);
}
